import Mock from 'mockjs'

const data = Mock.mock({
	'list|100': [{
		'title': '@ctitle',
		'desc': '@cword(10,30)',
		'id': '@id',
		'url': `https://robohash.org/@id`,
	}]
})

Mock.mock('/api/list', () => {
	return {
		code: 200,
		data: data.list
	}
})

Mock.mock('/api/search', 'post' ,(req) => {
	const { searchValue } = JSON.parse(req.body)
	return {
		code: 200,
		data: data.list.filter(item => item.title.includes(searchValue))
	}
})